package com.bw.zh32301.register

import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.bw.base.mvvm.BaseActivity
import com.bw.zh32301.databinding.ActivityMain2Binding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/MainActivity2")
class MainActivity2 : BaseActivity<ActivityMain2Binding, UserViewModel>() {
    override fun initView() {
        binding.btnLogin.setOnClickListener {
            viewModel.login(binding.loginPassword.text.toString(),binding.loginUsername.text.toString())
        }
        binding.tvSignAccount.setOnClickListener {
            ARouter.getInstance().build("/app/RegisterActivity").navigation()
        }
    }

    override fun initData() {
        viewModel.loginLiveData.observe(this){
            ARouter.getInstance().build("/app/HomeActivity").navigation()
            SPUtils.getInstance().put("token",it.token)

        }
    }
}